home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9541 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  54 lines

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Class problem
  5. Date: Sat, 02 Mar 1996 16:04:23 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4h9rgv$1ug@news.halcyon.com>
  8. References: <4gv6j2$klv@news-e2b.gnn.com> <4h2bvs$pop@brtph500.bnr.ca>
  9. NNTP-Posting-Host: blv-pm2-ip16.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. oophelp@bnr.ca (OOP Helpline) wrote:
  13.  
  14.  
  15. >|>                 class addr_data:public name_data
  16. >|>                 {
  17. >|>                  public:
  18. >|>                      char street[25];
  19. >|>                      char city[15];
  20. >|>                      char state[3];
  21. >|>                      int zip[11];
  22. >|>                      int phone[10];
  23. >|>                  }addr;
  24. >|> 
  25. >|> Can someone please tell me what is wrong with this picture?  I 
  26. >|> appreciate it.
  27.  
  28. >I see at least a half a dozen conceptual problems, such as improper
  29. >inheritance, lack of encapsulation, lack of aggregation...
  30.  
  31. >Just because you can get your C++ code to compile or even to run does
  32. >not mean you are doing it right.
  33.  
  34. This is what you get if you contact the "OOP Helpline?"
  35. Lost your job on the Suicide-Prevention Helpline, did you?
  36.  
  37. What, besides the spurious trailing addr, is really wrong with this?
  38. You're throwing around sanctimonious terms like "improper inheritence"
  39. and "lack of aggregation," but you fail to show why inheriting from
  40. something publicly would ever be improper, and why adding adress and
  41. phone number to name isn't aggregation.
  42.  
  43. I'll grant you one objection: "encapsulation" dictates one should
  44. access all these fields via methods instead of directly, and moreover
  45. the member variables should be protected or better.  However, if you
  46. were sending this data to your SQL-server, you might send it in a
  47. struct exactly like this.  
  48.  
  49. What's wrong with this picture is struct implies no methods, class
  50. implies methods and that's what get's OOP Helplines pissed.
  51.  
  52.                     --Norm 
  53.  
  54.